﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>方法推送 </title>
    <script type="text/javascript">
        //删除.
        function Del(mypk, nodeid) {
            if (mypk == '') {
                alert("默认发送不允许删除，您可以修改。");
                return;
            }
            if (window.confirm('您确定要删除吗?') == false)
                return;
            window.location.href = 'Method.htm?MyPK=' + mypk + '&DoType=Del&FrmID=' + nodeid;
        }
    </script>
    <link href="../../../DataUser/Style/ccbpm.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="../../Scripts/bootstrap/js/jquery.min.js"></script>
    <script src="../../Scripts/QueryString.js" type="text/javascript"></script>
    <script type="text/javascript" src="../../Scripts/config.js"></script>
    <script type="text/javascript" src="../../Comm/Gener.js"></script>
    <script src="../../Scripts/PinYin.js" type="text/javascript"> </script>
    <base target="_self" />
    <script type="text/javascript">
        function Esc() {
            if (event.keyCode == 27)
                window.close();
            return true;
        }

        /*隐藏与显示.*/
        function ShowHidden(ctrlID) {

            var ctrl = document.getElementById(ctrlID);
            if (ctrl.style.display == "block") {
                ctrl.style.display = 'none';
            } else {
                ctrl.style.display = 'block';
            }
        }
    </script>
    <script type="text/javascript" language="javascript">
        //页面启动函数.
        $(function () {

            var frmID = GetQueryString("FrmID");
            var ens = new Entities("BP.CCBill.Template.Methods");
            ens.Retrieve("FrmID", frmID, "Idx");

            for (var i = 0; i < ens.length; i++) {

               // var en = new Entity("BP.CCBill.Template.Method", ens[i]);

                var en =  ens[i];

                var newRow = "";
                newRow = "<tr ><td class=Idx>" + (i + 1) + "</td>";
                newRow += "<td>" + en.MethodID + "</td>";
                newRow += "<td><a href=\"javascript:Open('" + en.MyPK + "','" + en.RefMethodType + "');\"' >" + en.MethodName + "</a></td>";
                newRow += "<td>" + en.RefMethodTypeText + "</td>";
                newRow += "<td><img src='../../Img/Btn/Up.gif' onclick=\"Up('" + en.MyPK + "')\" alt='上移' />&nbsp;-&nbsp;<img src='../../Img/Btn/Down.gif' onclick=\"Down('" + en.MyPK + "')\" alt='下移' /> </td>";
                newRow += "<td>";
                if (en.RefMethodType != 2) {
                    newRow += " <a href=\"javascript:Paras('" + en.MyPK + "')\">参数</a> - ";
                newRow += " <a href=\"javascript:Docs('" + en.MyPK + "')\">执行内容</a> - ";
                }
                
                newRow += " <a href=\"javascript:Delete('" + en.MyPK + "')\"><img src='../../Img/Btn/Delete.gif' border=0 />删除</a>";

                newRow += "</td>";
                newRow += "</tr>";
                $("#Table1 tr:last").after(newRow);
            }
        });

        function Paras(mypk) {
            url = "MethodParas.htm?MyPK=" + mypk;
            WinOpenFull(url);
        }
        function Docs(mypk) {
            url = "MethodDoc.htm?MyPK=" + mypk;
            WinOpenFull(url);
        }

        //打开.
        function Open(mypk, type) {

            var url = "../../Comm/EnOnly.htm?EnName=BP.CCBill.Template.MethodLink&MyPK=" + mypk;
            if (type == 0)
                url = "../../Comm/En.htm?EnName=BP.CCBill.Template.MethodFunc&MyPK=" + mypk;
            WinOpenFull(url);
        }
        function Up(no) {
            var emp = new Entity("BP.CCBill.Template.Method", no);
            var data = emp.DoMethodReturnString("DoUp");
            window.location.href = window.location.href;
        }
        function Down(no) {

            var emp = new Entity("BP.CCBill.Template.Method", no);
            var data = emp.DoMethodReturnString("DoDown");
            window.location.href = window.location.href;
        }
        //删除.
        function Delete(myPK) {
            if (window.confirm('您确定要删除吗？') == false)
                return;
            var en = new Entity("BP.CCBill.Template.Method");
            en.MyPK = myPK;
            en.Delete();
            window.location.href = window.location.href;
        }
        //创建一个参数连接.
        function CreateMethodLink() {
            var name = window.prompt('请输入方法中文名称', "我的连接");
            if (name == null || name == undefined)
                return;

            var pinYin = ParsePinYin(name, true, null);

            var id = window.prompt('方法ID', pinYin);
            if (name == null || name == undefined)
                return;

            var en = new Entity("BP.CCBill.Template.Method");
            en.FrmID = GetQueryString("FrmID");
            en.MethodID = id;
            en.MethodName = name;
            en.RefMethodType = 2;
            en.SetPKVal(en.FrmID + "_" + en.MethodID);
            if (en.IsExits() == true) {
                alert('该方法名已经存在，请重新创建');
                return;
            }
            en.Insert();

            var url = "../../Comm/EnOnly.htm?EnName=BP.CCBill.Template.MethodLink&MyPK=" + en.MyPK;
            WinOpenFull(url);
            //window.location.href = window.location.href;
        }

        //创建一个参数连接.
        function CreateFunc() {
            var name = window.prompt('请输入方法中文名称', "注销学籍");
            if (name == null || name == undefined)
                return;

            var pinYin = ParsePinYin(name, true, null);

            var id = window.prompt('方法ID', pinYin);
            if (name == null || name == undefined)
                return;

            var en = new Entity("BP.CCBill.Template.Method");
            en.FrmID = GetQueryString("FrmID");
            en.MethodID = id;
            en.MethodName = name;
            en.RefMethodType = 0;
            en.SetPKVal(en.FrmID + "_" + en.MethodID);
            if (en.IsExits() == true) {
                alert('该方法名已经存在，请重新创建');
                return;
            }
            en.Insert();

            var url = "../../Comm/En.htm?EnName=BP.CCBill.Template.MethodFunc&MyPK=" + en.MyPK;
            WinOpenFull(url);
            //window.location.href = window.location.href;
        }

        function MethodDtl(eventType) {

            var url = 'MethodDtl.htm?FrmID=' + GetQueryString('FrmID');
            url += '&FK_Flow=' + GetQueryString('FK_Flow');
            url += '&FK_Event=' + eventType;
            url += '&tk=' + Math.random();

            window.location.href = url;
        }
        function Help() {
            var url = "http://ccbpm.mydoc.io";
            window.open(url);
        }
    </script>
</head>
<body onkeypress="Esc();" style="font-size: smaller">
    <table id="Table1" style="width: 100%">
        <caption>
            方法
        </caption>
        <tr>
            <th>
                序
            </th>
            <th>
                ID
            </th>
            <th>
                名称
            </th>
            <th>
                类型
            </th>
            <th>
                显示顺序
            </th>
            <th>
                操作
            </th>
        </tr>
    </table>
    <fieldset style="border: 0px;">
        <input type="button" value="帮助" onclick="Help()" />
        <input type="button" value="+新建方法" id="Btn_Save" onclick="ShowHidden('state')" />&nbsp;&nbsp;
        <div id="state" style="display: none; color: Gray">
            <ul>
                <li><a href="javascript:CreateMethodLink();">创建连接</a> </li>
                <!--<li><a href="javascript:CreateMethodLink('3');">超链接在新窗口打开方法</a> </li>-->
                <li><a href="javascript:CreateFunc();">执行功能方法</a> </li>
                <!--<li><a href="javascript:CreateFunc();">有参数的方法</a> </li>-->
            </ul>
        </div>
    </fieldset>
</body>
</html>
